package net.jlibrary.group.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;

import net.jlibrary.common.core.annotation.CodeGenComment;
import net.jlibrary.common.core.annotation.SearchCondition;
import net.jlibrary.common.core.annotation.SearchField;
import net.jlibrary.common.core.annotation.SeePurview;
import net.jlibrary.common.project.domain.Group;

/**
 * 商户
 * 
 * @author fzys
 *
 */
@Entity
@Table(name = "tab_merchant")
@PrimaryKeyJoinColumn(name = "group_id")
@BatchSize(size = 15)
@CodeGenComment(value = "商户管理", genSelect = false, add = false, update = false, delete = false)
@SeePurview(value = "globalPath")
public class Merchant extends Group {
	private static final long serialVersionUID = -6147453073316128236L;
	@ManyToOne(fetch = FetchType.LAZY)
	@SearchField(value = "area", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "所在区域", viewList = true, required = true)
	@JoinColumn(name = "area_id")
	private Area area;// 所在区域
	@Column(length = 50)
	@CodeGenComment(value = "联系人", viewSearch = true, maxLength = 20)
	private String linkman;// 联系人
	@Column(length = 100)
	@CodeGenComment(value = "联系电话", viewSearch = true, maxLength = 100)
	private String tel;// 联系电话
	@Column(length = 100)
	@SearchField(value = "mobile", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "手机号码", viewList = true, viewSearch = true, required = true, maxLength = 100)
	private String mobile;// 联系手机
	@Column(length = 100)
	@SearchField(value = "fax", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "传真号码", viewList = true, viewSearch = true, maxLength = 100)
	private String fax;// 传真
	@Column(length = 100)
	@SearchField(value = "email", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "E-mail", viewList = true, viewSearch = true, required = true, maxLength = 100)
	private String email;
	@Column(length = 200)
	@CodeGenComment(value = "简介", viewSearch = true, maxLength = 200)
	private String memo;// 简介

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public String getLinkman() {
		return linkman;
	}

	public void setLinkman(String linkman) {
		this.linkman = linkman;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public boolean equals(Object rhs) {
		if (rhs == null)
			return false;
		if (!(rhs instanceof Group))
			return false;
		Merchant that = (Merchant) rhs;
		if (this.getId() == null || that.getId() == null)
			return false;
		return (this.getId().equals(that.getId()));
	}

	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
		return result;
	}
}
